Skip to content

perf: schedule large contracts first in parallel compilation (LPT)#309

Merged
hedgar2017 merged 1 commit intomainfrom
perf/lpt-parallel-compilation
Mar 26, 2026
Merged

perf: schedule large contracts first in parallel compilation (LPT)#309
hedgar2017 merged 1 commit intomainfrom
perf/lpt-parallel-compilation

Conversation

@hedgar2017
Copy link
Contributor

@hedgar2017 hedgar2017 commented Mar 26, 2026

Implement the Longest-Processing-Time-First scheduling compilation time optimization.

  • Sort contracts by estimated compilation cost (descending) before parallel dispatch in compile_to_evm()
  • Uses par_bridge() for FIFO scheduling — worker threads pull contracts from the sorted queue in order
  • Large contracts start compiling first, reducing long-tail idle time when a single big contract would otherwise be the last one running while all other threads sit idle

Test plan

  • check if any projects have improved on compilation time

@hedgar2017 hedgar2017 requested a review from Copilot March 26, 2026 03:18
@hedgar2017 hedgar2017 self-assigned this Mar 26, 2026
@hedgar2017 hedgar2017 added the ci:integration Trigger integration tests workflow on PR label Mar 26, 2026
@hedgar2017 hedgar2017 requested review from a team March 26, 2026 03:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to reduce parallel compilation tail latency by scheduling the most expensive contracts first (LPT-style) before dispatching work in Project::compile_to_evm().

Changes:

  • Added Contract::estimated_compilation_cost() to estimate relative compilation cost from the contract’s IR representation.
  • Updated Project::compile_to_evm() to sort contracts by estimated cost (descending) and dispatch them via a FIFO-ish work queue using par_bridge().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
solx-core/src/project/mod.rs Sorts contracts by estimated cost and switches parallel dispatch to par_bridge() to prioritize large contracts.
solx-core/src/project/contract/mod.rs Introduces a cost-estimation helper used for scheduling decisions.

@hedgar2017 hedgar2017 force-pushed the perf/lpt-parallel-compilation branch 3 times, most recently from b61b398 to a69795e Compare March 26, 2026 03:40
@github-actions
Copy link

github-actions bot commented Mar 26, 2026

📊 solx Tester Report

➡️ Download

@github-actions
Copy link

github-actions bot commented Mar 26, 2026

📊 Hardhat Projects Report

➡️ Download

@github-actions
Copy link

github-actions bot commented Mar 26, 2026

📊 Foundry Projects Report

➡️ Download

@hedgar2017
Copy link
Contributor Author

Some Foundry improvements can be seen in the report, but it didn't help Hardhat unfortunately.

Sort contracts by estimated compilation cost descending before parallel
dispatch so that large contracts begin compiling first, reducing the
long-tail idle time when a single big contract is the last one running.

Uses par_bridge for FIFO scheduling guarantee via mutex-serialized
iterator consumption.
@hedgar2017 hedgar2017 force-pushed the perf/lpt-parallel-compilation branch from a69795e to 6e4de8c Compare March 26, 2026 13:36
@hedgar2017 hedgar2017 enabled auto-merge (squash) March 26, 2026 13:36
@hedgar2017 hedgar2017 merged commit 2d63d25 into main Mar 26, 2026
48 of 50 checks passed
@hedgar2017 hedgar2017 deleted the perf/lpt-parallel-compilation branch March 26, 2026 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:integration Trigger integration tests workflow on PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants